package com.lsh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lsh.pojo.LoginTicket;
import com.lsh.dao.LoginTicketMapper;
import com.lsh.service.ILoginTicketService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 刘书豪
 * @since 2022-07-22
 */
@Service
public class LoginTicketServiceImpl extends ServiceImpl<LoginTicketMapper, LoginTicket> implements ILoginTicketService {
    @Resource
    LoginTicketMapper loginTicketMapper;
    @Override
    public LoginTicket getTicketByTicket(String ticket) {
        QueryWrapper<LoginTicket> wrapper = new QueryWrapper<>();
        wrapper.eq("ticket",ticket);
        return loginTicketMapper.selectOne(wrapper);
    }
    public LoginTicket getTicketByUserId(int id) {
        QueryWrapper<LoginTicket> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",id);
        return loginTicketMapper.selectOne(wrapper);
    }
    @Override
    public int insert(LoginTicket loginTicket) {
        loginTicketMapper.insert(loginTicket);
        return 0;
    }

}
